package com.geovis.emergency.spd.entity.pc.pojo.vo;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.geovis.emergency.spd.entity.pc.entity.PcPlanDutyOrg;
import com.geovis.emergency.spd.entity.pc.entity.PcPlanOrgUser;
import com.geovis.emergency.spd.entity.system.pojo.node.INode;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>
 *
 * </p>
 *
 * @author Lonsho
 * @version 1.0
 * @date 2022/7/12
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class PcPlanDutyOrgVO extends PcPlanDutyOrg implements INode<PcPlanDutyOrgVO> {

    @ApiModelProperty(value = "角色集合（多天以,分隔）")
    private String roleNames;

    @ApiModelProperty(value = "子集列表")
    @JsonInclude(JsonInclude.Include.NON_EMPTY)
    private List<PcPlanDutyOrgVO> children;

    @ApiModelProperty("组织架构人员")
    private List<PcPlanOrgUser> dutyOrgDeptList;
    /**
     * 是否有子孙节点
     */
    @JsonInclude(JsonInclude.Include.NON_NULL)
    private Boolean hasChildren;

    @Override
    public Boolean getHasChildren() {
        return getChildren().size() > 0 ? true:null;
    }
    @Override
    public List<PcPlanDutyOrgVO> getChildren() {
        if (this.children == null) {
            this.children = new ArrayList<>();
        }
        return this.children;
    }
}
